﻿#region Using

using System;

using Common.Base;

using Microsoft.Xna.Framework;

#endregion

namespace Common
{
    public static class Utils
    {
        public static int? GetIntOrNull(string value)
        {
            int result;
            return int.TryParse(value, out result) ? result : (int?)null;
        }

        public static int GetIntOrZero(string value)
        {
            int result;
            return int.TryParse(value, out result) ? result : 0;
        }

        public static bool EnumFromString<T>(string value, out T parsedValue) where T : struct
        {
            return Enum.TryParse(value, out parsedValue);
        }

        public static T EnumFromString<T>(string value) where T : struct
        {
            return (T)Enum.Parse(typeof(T), value);
        }
    }
}